import java.util.Comparator;
import java.util.PrimitiveIterator;
import java.util.PriorityQueue;
class intCom implements Comparator<Integer>{

    @Override
    public int compare(Integer o1, Integer o2) {
        return o2.compareTo(o1);
    }
}
public class Test {
    public static void main(String[] args) {
        PriorityQueue<Integer> priorityQueue=new PriorityQueue<>(new intCom());
        priorityQueue.offer(1);
        priorityQueue.offer(2);
        priorityQueue.offer(3);
        System.out.println(priorityQueue.peek());
    }
    public static void main1(String[] args) {
        TestHeap testHeap=new TestHeap();
        int[] array={ 27,15,19,18,28,34,65,49,25,37};
        testHeap.iniElem(array);

    }
    public int[] smallestK(int[] arr, int k) {
        int[] elem=new int[k];
        if(k==0||arr==null){
            return elem;
        }
        PriorityQueue<Integer> priorityQueue=new PriorityQueue<>(new intCom());
        for(int i=0;i<k;i++){
            priorityQueue.offer(arr[i]);
        }
        for(int j=k;j<arr.length;j++){
            int peekval=priorityQueue.peek();
            if(arr[j]<peekval){
                priorityQueue.poll();
                priorityQueue.offer(arr[j]);
            }
        }
        for(int i=0;i<k;i++){
            elem[i]=priorityQueue.poll();
        }
        return elem;

    }
}

